<template>
  <!-- 访客记录-详情 -->
  <div>
    <public-modal
      width="1000px"
      :footer="false"
      title="现居人员列表"
      modalStyle="detailModal"
      :publicVisible="publicVisible"
      cancelContext="拒绝"
      confirmContext="通过"
      @handleOk="handleOk"
      @cancel="cancel"
    >
      <div slot="content">
        <div class="common-title">
          <div class="icon"></div>
          <div class="content">房屋地址</div>
        </div>

        <div class="content-wrapper">
          <div class="flex">
            <div class="info-wrap f1">
              <div class="value common-value">{{ isTsyfwinfo.infoNames || '暂无' }}</div>
            </div>
          </div>
        </div>

        <div class="common-title">
          <div class="icon"></div>
          <div class="content">现居人员</div>
        </div>

        <a-table
          rowKey="id"
          class="tableList"
          :columns="columns"
          :dataSource="housePopulationlist"
          :pagination="false"
          style="margin: 20px 0; border: 1px solid #154b81"
        >
          <template #time="record">
            <a-tooltip placement="topLeft">
              <template slot="title">
                <span>{{ record.startTime.split(' ')[0] }} - {{ record.endTime.split(' ')[0] }}</span>
              </template>
              <span>{{ record.startTime.split(' ')[0] }} - {{ record.endTime.split(' ')[0] }}</span>
            </a-tooltip>
          </template>
          <template v-slot:action="records">
            <span class="operation deatil-color" @click="detailHandle(records)">详情 </span>
          </template>
        </a-table>

        <div class="common-title">
          <div class="icon"></div>
          <div class="content">历史居民</div>
        </div>

        <a-table
          rowKey="id"
          class="tableList"
          :columns="historyResident"
          :dataSource="houseHistoryList"
          :pagination="false"
          @change="handleTableChange"
          style="margin: 20px 0; border: 1px solid #154b81"
        >
          <template #time="record">
            <a-tooltip placement="topLeft">
              <template slot="title">
                <span>{{ record.startTime.split(' ')[0] }} - {{ record.endTime.split(' ')[0] }}</span>
              </template>
              <span>{{ record.startTime.split(' ')[0] }} - {{ record.endTime.split(' ')[0] }}</span>
            </a-tooltip>
          </template>
          <template v-slot:action="records">
            <span class="operation deatil-color" @click="detailHandle(records)">详情 </span>
          </template>
        </a-table>
      </div>
      <div slot="footer"></div>
    </public-modal>

    <PopulationDetail ref="populationDetailRef" />
  </div>
</template>
<script>
import startEndTime from '@/components/startEndTime'
import publicModal from '@/components/publicModal'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { houseDetails } from '@/api/api'
import PopulationDetail from '../../actuallyPopulation/modules/populationDetail.vue'

export default {
  name: 'currentResident',
  components: { publicModal, startEndTime, PopulationDetail },
  mixins: [JeecgListMixin],
  data() {
    return {
      url: {
        list: '/common/project_company_serve_record/page',
      },
      publicVisible: false,
      details: {},
      columns: [
        {
          title: '序号',
          align: 'center',
          width: 100,
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          },
        },
        {
          title: '人员姓名',
          align: 'center',
          dataIndex: 'fXm',
          ellipsis: true,
        },
        {
          title: '与房主关系',
          align: 'center',
          dataIndex: 'fCjrxmType',
          ellipsis: true,
        },
        {
          title: '联系方式',
          align: 'center',
          dataIndex: 'fLxdh',
          ellipsis: true,
        },
        {
          title: '身份证号',
          align: 'center',
          dataIndex: 'fGmsfhm',
          ellipsis: true,
          width: 200,
        },
        {
          title: '操作',
          scopedSlots: { customRender: 'action' },
          align: 'center',
        },
      ],
      historyResident: [
        {
          title: '序号',
          align: 'center',
          width: 100,
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          },
        },
        {
          title: '人员姓名',
          align: 'center',
          ellipsis: true,
          dataIndex: 'fXm',
        },
        {
          title: '身份证号',
          align: 'center',
          dataIndex: 'fGmsfhm',
          ellipsis: true,
          width: 200,
        },
        {
          title: '移除时间',
          align: 'center',
          dataIndex: 'removeDate',
          ellipsis: true,
        },
        {
          title: '操作',
          scopedSlots: { customRender: 'action' },
          align: 'center',
        },
      ],
      project_company_type: [],
      queryParams: { pageSize: 5 },
      ipagination: { pageSize: 5 },
      disableMixinCreated: true,
      housePopulationlist: [],
      isTsyfwinfo: {},
      houseHistoryList: [],
    }
  },

  methods: {
    async show(records) {
      this.publicVisible = true
      this.getDetail(records)
    },
    getDetail(records) {
      const params = {
        id: records.fHouseid,
      }
      houseDetails(params).then((res) => {
        if (res.code == 200) {
          const { isTsyfwinfo, housePopulationlist, houseHistoryList } = res.result
          this.isTsyfwinfo = isTsyfwinfo
          this.housePopulationlist = housePopulationlist
          this.houseHistoryList = houseHistoryList
        } else {
        }
      })
    },

    detailHandle(records) {
      this.$refs.populationDetailRef.show({ ...records, id: records.fId })
    },

    handleOk() {
      this.publicVisible = false
    },

    cancel(target) {
      this.publicVisible = false
    },
  },
}
</script>
<style scoped lang="less">
/deep/ .modalCotent {
  padding: 20px 40px;
  border-radius: 0 0 4px 4px;
}
</style>
